/*   1:    */ package com.jetbrains.licenseService.util;
/*   2:    */ 
/*   3:    */

import com.jetbrains.licenseService.requests.ObtainLicenseRequest;
import com.jetbrains.licenseService.requests.ObtainUserIdRequest;
import com.jetbrains.licenseService.requests.PingRequest;
import com.jetbrains.licenseService.requests.ValidateLicenseRequest;
import com.jetbrains.licenseService.responses.ObtainLicenseResponse;
import com.jetbrains.licenseService.responses.ObtainUserIdResponse;
import com.jetbrains.licenseService.responses.PingResponse;
import com.jetbrains.licenseService.responses.ValidateLicenseResponse;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import java.util.prefs.Preferences;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */ 
/*  20:    */ public class ClientUtil
/*  21:    */ {
/*  22: 29 */   private static final String a = ;
/*  23: 30 */   private static final String b = System.getProperty("user.name", "<unknown>");
/*  24:    */   private static final String c;
/*  25:    */   
/*  26:    */   static
/*  27:    */   {
/*  28: 31 */     String str = Preferences.userRoot().get("JetBrains.UserIdOnMachine", null);
/*  29: 32 */     if ((str == null) || (str.length() == 0))
/*  30:    */     {
/*  31: 33 */       str = UUID.randomUUID().toString();
/*  32: 34 */       Preferences.userRoot().put("JetBrains.UserIdOnMachine", str);
/*  33:    */     }
/*  34: 36 */     c = str;
/*  35:    */   }
/*  36:    */   
/*  37: 37 */   private static final AbstractRequest.UserIdentification d = new AbstractRequest.UserIdentification(c, a, b);
/*  38:    */   
/*  39:    */   public static String getMachineId()
/*  40:    */   {
/*  41: 41 */     return d.getMachineId();
/*  42:    */   }
/*  43:    */   
/*  44:    */   public static String getHostName()
/*  45:    */   {
/*  46: 46 */     return d.getHostName();
/*  47:    */   }
/*  48:    */   
/*  49:    */   public static String getUserName()
/*  50:    */   {
/*  51: 50 */     return d.getUserName();
/*  52:    */   }
/*  53:    */   
/*  54:    */   public static PingResponse ping(String paramString)
/*  55:    */     throws VerificationFailedException, IOException
/*  56:    */   {
/*  57: 54 */     PingRequest localPingRequest = new PingRequest();
/*  58: 55 */     localPingRequest.setMachineId(c);
/*  59: 56 */     localPingRequest.setUserName(getUserName());
/*  60: 57 */     localPingRequest.setHostName(getHostName());
/*  61: 58 */     localPingRequest.setProductCode(paramString);
/*  62: 59 */     localPingRequest.setSalt(System.currentTimeMillis());
/*  63: 60 */     return (PingResponse)RpcUtil.executeRpc(localPingRequest);
/*  64:    */   }
/*  65:    */   
/*  66:    */   public static ObtainUserIdResponse obtainUserId(@NotNull String paramString1, @NotNull String paramString2, String paramString3)
/*  67:    */     throws IOException, VerificationFailedException
/*  68:    */   {
/*  69: 64 */     if (paramString1 == null) {
/*  70: 64 */       throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "loginName", "com/jetbrains/licenseService/util/ClientUtil", "obtainUserId" }));
/*  71:    */     }
/*  72: 64 */     if (paramString2 == null) {
/*  73: 64 */       throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "password", "com/jetbrains/licenseService/util/ClientUtil", "obtainUserId" }));
/*  74:    */     }
/*  75: 64 */     ObtainUserIdRequest localObtainUserIdRequest = new ObtainUserIdRequest(System.currentTimeMillis(), c, getHostName(), getUserName(), paramString3);
/*  76: 65 */     localObtainUserIdRequest.setLoginName(paramString1);
/*  77: 66 */     localObtainUserIdRequest.setPassword(paramString2);
/*  78: 67 */     return RpcUtil.executeRpc(localObtainUserIdRequest);
/*  79:    */   }
/*  80:    */   
/*  81:    */   public static ObtainLicenseResponse obtainLicenses(String paramString1, String paramString2, int paramInt, String paramString3, long paramLong)
/*  82:    */     throws IOException, VerificationFailedException
/*  83:    */   {
/*  84: 71 */     return (ObtainLicenseResponse)RpcUtil.executeRpc(new ObtainLicenseRequest(System.currentTimeMillis(), paramString1, c, getHostName(), getUserName(), paramString2, paramString3, paramInt, paramLong));
/*  85:    */   }
/*  86:    */   
/*  87:    */   public static ValidateLicenseResponse validateLicense(String paramString1, String paramString2, String paramString3, int paramInt, String paramString4, long paramLong)
/*  88:    */     throws IOException, VerificationFailedException
/*  89:    */   {
/*  90: 77 */     return (ValidateLicenseResponse)RpcUtil.executeRpc(new ValidateLicenseRequest(System.currentTimeMillis(), paramString1, paramString2, c, getHostName(), getUserName(), paramString3, paramString4, paramInt, paramLong));
/*  91:    */   }
/*  92:    */   
/*  93:    */   public static Date parseDate(@NotNull String paramString)
/*  94:    */     throws ParseException
/*  95:    */   {
/*  96: 83 */     if (paramString == null) {
/*  97: 83 */       throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "str", "com/jetbrains/licenseService/util/ClientUtil", "parseDate" }));
/*  98:    */     }
/*  99: 83 */     return new SimpleDateFormat("yyyy-MM-dd").parse(paramString);
/* 100:    */   }
/* 101:    */   
/* 102:    */   public static String formatDate(@NotNull Date paramDate)
/* 103:    */   {
/* 104: 87 */     if (paramDate == null) {
/* 105: 87 */       throw new IllegalArgumentException(String.format("Argument for @NotNull parameter '%s' of %s.%s must not be null", new Object[] { "date", "com/jetbrains/licenseService/util/ClientUtil", "formatDate" }));
/* 106:    */     }
/* 107: 87 */     return new SimpleDateFormat("yyyy-MM-dd").format(paramDate);
/* 108:    */   }
/* 109:    */   
/* 110:    */   public static String formatDate(long paramLong)
/* 111:    */   {
/* 112:    */     Date localDate;
/* 113:    */     try
/* 114:    */     {
/* 115: 97 */       localDate = new SimpleDateFormat("yyyyMMdd").parse(String.valueOf(paramLong));
/* 116:    */     }
/* 117:    */     catch (ParseException localParseException)
/* 118:    */     {
/* 119:100 */       localDate = new Date(paramLong);
/* 120:    */     }
/* 121:102 */     return formatDate(localDate);
/* 122:    */   }
/* 123:    */ }



/* Location:           E:\idea\

 * Qualified Name:     com.jetbrains.licenseService.util.ClientUtil

 * JD-Core Version:    0.7.0.1

 */